package dev.loong.boot3.vo;

import com.alibaba.excel.annotation.ExcelProperty;
import dev.loong.boot3.commons.SexEnum;
import dev.loong.boot3.pojo.User;
import lombok.Data;

import java.util.List;

@Data
public class UserVo {
    @ExcelProperty("编号")
    private Long id;
    @ExcelProperty("姓名")
    private String userName;
    @ExcelProperty("密码")
    private String pwd;
    //private Integer sexId;
    //private String sexName;

    private int available;
    @ExcelProperty("备注")
    private String note;

    public static User changeToPo(UserVo userVo) {
        User user = new User();
        user.setId(userVo.getId());
        user.setUserName(userVo.getUserName());
        user.setPwd(userVo.getPwd());
        user.setNote(userVo.getNote());
        user.setAvailable(userVo.getAvailable());
        //user.setSex(SexEnum.getSex(userVo.getSexId()));
        return user;
    }
    public static UserVo changeToVo(User user) {
        UserVo userVo = new UserVo();
        userVo.setId(user.getId());
        userVo.setUserName(user.getUserName());
        //userVo.setPwd(user.getPwd());
        userVo.setNote(user.getNote());
        //userVo.setSexId(user.getSex().getCode());
        //userVo.setSexName(user.getSex().getName());
        userVo.setAvailable(user.getAvailable());
        return userVo;
    }

    public static List<UserVo> changeToVoes(List<User> poList) {
        var voList = poList.stream().map(po -> changeToVo(po)).toList();
        return voList;
    }
}
